#ifndef VECTOR2_H
#define VECTOR2_H

typedef struct {
	int x;
	int y;
}Vector2S;

typedef struct{
	Vector2S *pVector2s;
	void *(*add)(void*,void*);	
}*V2sp;

typedef struct{
	 Vector2S v2s;
	 Vector2S (*_add)(Vector2S,Vector2S);
	 double (*_getDis)(Vector2S,Vector2S);	
}Vector2;

Vector2S _addf(Vector2S v2s1,Vector2S v2s2){
	Vector2S v2sRet={
		.x = v2s1.x + v2s2.x,
		.y=v2s1.y+v2s2.y
	};
	return v2sRet;
}
double _getDisf(Vector2S v2s1,Vector2S v2s2){
	double dis = 0;	
	int dx =fabs(v2s1.x - v2s2.x);
	int dy =fabs(v2s1.y - v2s2.y);
	dis = pow(dx*dx+dy*dy,0.5);
	return dis;
} 
Vector2 _vector2={._add=_addf,._getDis=_getDisf};

V2sp* addf(V2sp *v1,V2sp *v2){
	 V2sp *vec1 = (V2sp*)v1;
	return v1;
}

void testV2sp(){
	
}
void test_vector2(){
	Vector2S Vect2[2] = {
	{
	.x=1,.y=1
},{
	.x=2,.y=2
	}};
	Vector2S v = _vector2._add(Vect2[0],Vect2[1]);
	printf("v.x=%d\nv.y=%d\n",v.x,v.y);
}
void test_v2sDis(){
	Vector2S Vect2[2] = {
	{
	.x=1,.y=1
},{
	.x=2,.y=2
	}};
	double dis = _vector2._getDis(Vect2[0],Vect2[1]);
	int cv = (int)dis;
	printf("dis=%d\n",cv);
}
#endif
